import React from 'react';

import ListPage from '@common/listPage';
import { DemoType, ExampleType } from '@/types.d';
import { createDemoType } from '@utils/typeHandler'

import addEventListener from './addEventListener';
import openURL from './openUrl';

const NAME = 'Linking';
const CATEGORY = 'API';
const DESCRIPTION = t('api.Linking.description');

const demoList: DemoType[] = [
    {
        name: 'addEventListener',
        description: t('api.Linking.addEventListener.description'),
        component: addEventListener,
    },
    {
        name: 'openURL',
        description: t('api.Linking.openURL.description'),
        component: openURL,
    },
].map((item) => {
    return createDemoType({ ...item, id: `${CATEGORY}_${NAME}_${item.name}` })
});

const Example: ExampleType['component'] = ({ navigation }) => {

    return (
        <>
            {ListPage({
                title: NAME,
                list: demoList,
                navigation
            })}
        </>
    )
}

const LinkingExample: ExampleType = {
    id: `${CATEGORY}_${NAME}`,
    name: NAME,
    description: DESCRIPTION,
    category: CATEGORY,
    component: Example,
    children: demoList,
}

export default LinkingExample;